const Koa = require('koa');
const app = new Koa()
var router = require('koa-router')();

const Mock = require('mockjs');
// 获取 mock.Random 对象
const Random = Mock.Random;

//首页广告
router.get('/mockdata',function(ctx,next){
    let data = {
        id: Random.natural(),
        commodityId: Random.guid(),
        commodityName: Random.ctitle(4),
        commodityTime: Random.date() + ' ' + Random.time()
    }  
	ctx.body = data;
})

//开启服务
const serve = require('koa-static');
app.use(serve(__dirname + '/images'));
app.use(router.routes())
   .use(router.allowedMethods());
var config=require("./config/config")
app.listen(config.port);